home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
program
/
dxt135.zip
/
DXT.CB
< prev
next >
Wrap
Text File
|
1996-08-03
|
44KB
|
1,262 lines
/*****************************************************************************/
/*
DXT.CB - BRIEF MACRO FUNCTIONS FOR
DFTN (TM) DBASE FUNCTION TREE NAVIGATOR
Copyright (C) Juergen Mueller (J.M.) 1992-1996
All rights reserved.
You are expressly prohibited from selling this software in any form,
distributing it with another product, or removing this notice.
Limited permission is given to registered DXT users to modify this
file for their own personal use only. This file may not be used for any
purpose other than in conjunction with the DXT software package.
THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE
IMPLIED WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
PROGRAM AND DOCUMENTATION IS WITH YOU.
written by: Juergen Mueller, Aldingerstrasse 22, D-70806 Kornwestheim,
GERMANY
FILE : DXT.CB
REVISION : 27-Apr-1996
18:30:41
*/
/*****************************************************************************/
#include "dialog.h" /* include file from original BRIEF DIALOG menus */
/*****************************************************************************/
/* defines */
/*****************************************************************************/
#define TMPFILE "DXTFILE.TMP"
#define DFTNPROG "dftn" /* or "dftn4os2" for OS/2 */
/* or "dftn32" for Windows NT / Windows 95 */
#ifdef __OS2__
#define upper(x) (x)
#endif
/*****************************************************************************/
/**** USER macro function prototypes ****/
/*****************************************************************************/
void dft(void);
void dftfind(void);
void dftmenu(void);
void dftbase(void);
void dftfilemenu(void);
void dftxrefmenu(void);
void dftxrefmenuagain(void);
void dftdefmenu(void);
/*****************************************************************************/
/**** INTERNAL macro function prototypes ****/
/*****************************************************************************/
void _init(void); /* initialisation function, called on entry */
void _dxtmenu_exit(void);
void _exec_error(int retval, string format, string par1, string par2);
string _extract_item(void);
void _dxt(string, string);
void _dxt_search(string, string, string, int, int);
void _dxt_edit_file(void);
void _dxt_locate(void);
void _dxt_buffers(void);
void _dxtmenu(string, string);
int _dft_action(int, ...);
void _dxtfilemenu(string, string);
int _dxt_fileaction(int, ...);
void _dxtxrefmenu(string, string, int);
int _dxt_xrefaction(int, ...);
void _dxtdefmenu(string, string);
int _dxt_defaction(int, ...);
void _dxt_insert_sorted(string, int, int);
/*****************************************************************************/
/**** global variables ****/
/*****************************************************************************/
string dft_base; /* data base name for dft */
string dxt_loc; /* resulting file with item location */
string dxt_item; /* item to search for */
int dxt_id; /* item id */
string dxt_file; /* target file name */
int dxt_line; /* target line, used by registered macro */
string dft_loc; /* resulting file for menu */
int dft_menuwidth; /* horizontal dft menu width */
string dft_files; /* resulting file for filemenu */
int dft_filemenuwidth; /* horizontal dft filemenu width */
string dft_xref;
string dft_xref_item;
int dft_xrefmenuwidth;
string dft_deffile;
string dft_def_item;
int dft_defmenuwidth;
/*****************************************************************************/
/**** macro package initialization function ****/
/*****************************************************************************/
void _init(void)
{
/* init DFT base with environment */
dft_base = trim(ltrim(inq_environment("DFTNBASE")));
dxt_loc = "dxt.loc"; /* intermediate file for search results */
dft_loc = "dft.loc"; /* used for function menu */
dft_files = "dft_file.loc"; /* used for function file menu */
dft_xref = "dft_xref.loc";
dft_xref_item = "";
dft_deffile = "dft_def.loc";
dft_def_item = "";
/* register macro to delete temporary files on exit from BRIEF */
register_macro(5, "_dxtmenu_exit");
}
/*****************************************************************************/
/* registered macro to perform actions on exit of BRIEF or */
/* if changes of database names have happened */
/*****************************************************************************/
void _dxtmenu_exit(void)
{
if (exist(dft_loc))
del(dft_loc);
if (exist(dft_files))
del(dft_files);
if (exist(dft_xref))
del(dft_xref);
if (exist(dft_deffile))
del(dft_deffile);
}
/*****************************************************************************/
/**** user callable macros ****/
/*****************************************************************************/
void dft(void) /* find function */
{
_dxt(DFTNPROG, dft_base); /* do function retrieval */
}
void dftfind(void) /* find user defined item */
{
string item;
get_parm(NULL, item, "DFT function name: ", 50);
item = compress(trim(ltrim(item)));
if (strlen(item))
_dxt_search(DFTNPROG, dft_base, item, 0, 0);
}
void dftmenu(void) /* build function menu */
{
_dxtmenu(DFTNPROG, dft_base);
}
void dftbase(void) /* set DFT database name */
{
get_parm(NULL, dft_base, "DFT database name: ", 50, dft_base);
dft_base = trim(ltrim(dft_base));
_dxtmenu_exit(); /* delete menu files */
}
void dftfilemenu(void) /* build DFT file menu */
{
_dxtfilemenu(DFTNPROG, dft_base);
}
void dftxrefmenu(void) /* build function cross reference menu */
{
_dxtxrefmenu(DFTNPROG, dft_base, 1);
}
void dftxrefmenuagain(void) /* rebuild menu for previous item */
{
_dxtxrefmenu(DFTNPROG, dft_base, 0);
}
void dftdefmenu(void)
{
_dxtdefmenu(DFTNPROG, dft_base);
}
/*****************************************************************************/
/**** internal macro execution functions ****/
/*****************************************************************************/
/*****************************************************************************/
/* */
/*****************************************************************************/
void _exec_error(int retval, string format, string par1, string par2)
{
if (retval >= 100)
message(format, par1, par2);
else
message("Command execution error (%d)", retval);
}
/*****************************************************************************/
/* read search item from current buffer */
/*****************************************************************************/
string _extract_item(void)
{
int move_flag, markval, marklen;
int start_line, start_col, end_line, end_col;
string itemname, act_char, tmp_char, fchar, nchar;
fchar = "[_a-zA-Z]"; /* first character of an identifier */
nchar = "[_a-zA-Z0-9]"; /* not first character of an identifier */
if (!(markval = inq_marked(start_line, start_col, end_line, end_col)))
{ /* nothing marked, use cursor position */
if (!search_string(nchar, read(1)))
{
message("Invalid cursor position");
return "";
}
save_position(); /* save the current position */
act_char = read(1); /* read current character */
whil